import playerHandle from "js/handle/playerHandle"
import eventEmitter from "./eventEmitter"
import Random from "./random"
import { gameConfigHandle } from 'js/config/gameConfig'
import { PlayerModel } from "js/model/playerModel"


export let routeApiConfig = {
	isClient: true,
	isLocal: true,
	version: "1.1",
	serverApi: null,
	clientRouteApi: null,
}

export interface GameTime {
  time: number,
  dayTime: number
}

export interface GameRouteData {
  player: PlayerModel
  time: number,
  dayTime: number
  version: string
  random: Random
}

export function localApi(routeName: string) {
  return (target, property, descriptor: PropertyDescriptor) => {
    let func = descriptor.value
    descriptor.value = async (...values) => {
      if (routeApiConfig.isClient) {
				let res = await routeApiConfig.clientRouteApi(property, func, routeName, ...values)
				return res
			} else {
				let res = func(...values)
				return { err: res.err, data: res.data }
			}
    }
  }
}

export let playerUpdateFunc = {
  cb: null
}

async function add() {

}

